package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.FilmInformation;
import com.ruoyi.system.service.IFilmInformationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 影片信息Controller
 * 
 * @author ruoyi
 * @date 2024-06-28
 */
@RestController
@RequestMapping("/system/information")
public class FilmInformationController extends BaseController
{
    @Autowired
    private IFilmInformationService filmInformationService;

    /**
     * 查询影片信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:information:list')")
    @GetMapping("/list")
    public TableDataInfo list(FilmInformation filmInformation)
    {
        startPage();
        List<FilmInformation> list = filmInformationService.selectFilmInformationList(filmInformation);
        return getDataTable(list);
    }

    /**
     * 导出影片信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:information:export')")
    @Log(title = "影片信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FilmInformation filmInformation)
    {
        List<FilmInformation> list = filmInformationService.selectFilmInformationList(filmInformation);
        ExcelUtil<FilmInformation> util = new ExcelUtil<FilmInformation>(FilmInformation.class);
        util.exportExcel(response, list, "影片信息数据");
    }

    /**
     * 获取影片信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:information:query')")
    @GetMapping(value = "/{filmId}")
    public AjaxResult getInfo(@PathVariable("filmId") Long filmId)
    {
        return success(filmInformationService.selectFilmInformationByFilmId(filmId));
    }

    /**
     * 新增影片信息
     */
    @PreAuthorize("@ss.hasPermi('system:information:add')")
    @Log(title = "影片信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FilmInformation filmInformation)
    {
        return toAjax(filmInformationService.insertFilmInformation(filmInformation));
    }

    /**
     * 修改影片信息
     */
    @PreAuthorize("@ss.hasPermi('system:information:edit')")
    @Log(title = "影片信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FilmInformation filmInformation)
    {
        return toAjax(filmInformationService.updateFilmInformation(filmInformation));
    }

    /**
     * 删除影片信息
     */
    @PreAuthorize("@ss.hasPermi('system:information:remove')")
    @Log(title = "影片信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{filmIds}")
    public AjaxResult remove(@PathVariable Long[] filmIds)
    {
        return toAjax(filmInformationService.deleteFilmInformationByFilmIds(filmIds));
    }
}
